Mission launch and lots of fixes and tests

James Peret 10 years ago
parent
commit
e40bf4052d

+ 13 - 0
app/assets/stylesheets/avl2_theme/buttons.less

@@ -50,6 +50,19 @@
50 50
 	line-height: 20px;
51 51
 }
52 52
 
53
+.btn-huge {
54
+  font-family: Avenir-Black;
55
+  font-size: 36px;
56
+  color: #333333;
57
+  line-height: 40px;
58
+  padding-left: 0px;
59
+  padding-right: 0px;
60
+  padding-top: 15px;
61
+  padding-bottom: 10px;
62
+  width: 280px;
63
+  text-transform: uppercase;
64
+}
65
+
53 66
 .btn:hover {
54 67
 	background: rgba(0, 0, 0, 0.2);
55 68
 }

+ 34 - 0
app/controllers/mission_editor/details_controller.rb

@@ -0,0 +1,34 @@
1
+class MissionEditor::DetailsController < ApplicationController
2
+  
3
+  before_action :set_mission
4
+  before_action :check_user
5
+  
6
+  def launch
7
+    
8
+  end
9
+  
10
+  def launch_mission
11
+    if @mission.launch
12
+      redirect_to mission_control_path(@mission), notice: (t 'mission_editor.mission_launched')
13
+    else
14
+      redirect_to mission_path(@mission), alert: (t 'mission_editor.launch_error')
15
+    end
16
+  end
17
+  
18
+  private
19
+
20
+    def set_mission
21
+       @mission = Mission.friendly.find(params[:mission])
22
+    end
23
+    
24
+    def check_user
25
+      if user_signed_in?
26
+        if current_user != @mission.owner
27
+          redirect_to mission_path(mission), alert: (t 'mission_editor.insuficient_privileges')
28
+        end
29
+      else
30
+        redirect_to new_user_session_path, notice: (t 'registration.please_log_in_first')
31
+      end
32
+    end
33
+
34
+end

+ 3 - 16
app/controllers/missions_controller.rb

@@ -72,6 +72,7 @@ class MissionsController < ApplicationController
72 72
   def update
73 73
     respond_to do |format|
74 74
       if @mission.update(mission_params)
75
+        puts mission_params
75 76
         format.html { redirect_to mission_control_path(@mission), notice: 'Mission was successfully updated.' }
76 77
         format.json { head :no_content }
77 78
       else
@@ -91,20 +92,6 @@ class MissionsController < ApplicationController
91 92
     end
92 93
   end
93 94
   
94
-  def launch
95
-    mission = Mission.friendly.find(params[:id])
96
-    if user_signed_in?
97
-      if current_user == mission.owner
98
-        mission.update(status: 2)
99
-        redirect_to mission_control_path(mission)
100
-      else
101
-        redirect_to mission_path(mission), alert: (t 'mission.insuficient_privileges')
102
-      end
103
-    else
104
-      redirect_to new_user_session_path, notice: (t 'registration.please_log_in_first')
105
-    end
106
-  end
107
-  
108 95
   def take_agent_role
109 96
     mission = Mission.friendly.find(params[:id])
110 97
     agent = mission.mission_agents.friendly.find(params[:agent])
@@ -178,11 +165,11 @@ class MissionsController < ApplicationController
178 165
 
179 166
     # Never trust parameters from the scary internet, only allow the white list through.
180 167
     def mission_params
181
-      params.require(:mission).permit(:mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img, :slug, :end_date)
168
+      params.require(:mission).permit(:mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img, :slug, :end_date, :duration_scale, :duration_number)
182 169
     end
183 170
     
184 171
     def step_submission_params
185
-      params.require(:step_submission).permit(:agent_step_id, :validated, :validated_by_id, :date_validated, :created_at, :updated_at, :language, :cover_img, :slug, :end_date, :submission_contents_attributes => [:submission_content_id, :submission_type, :created_at, :updated_at, :submission_attributes => [:content, :submission_content_id]])
172
+      params.require(:step_submission).permit(:agent_step_id, :validated, :validated_by_id, :date_validated, :created_at, :updated_at, :language, :cover_img, :slug, :end_date,  :submission_contents_attributes => [:submission_content_id, :submission_type, :created_at, :updated_at, :submission_attributes => [:content, :submission_content_id]])
186 173
     end
187 174
     
188 175
 end

+ 16 - 11
app/models/mission.rb

@@ -13,9 +13,6 @@ class Mission < ActiveRecord::Base
13 13
   mount_uploader :cover_img, MissionCoverUploader
14 14
   process_in_background :cover_img
15 15
   
16
-  attr_writer :duration_scale
17
-  attr_writer :duration_number
18
-  
19 16
   after_initialize do |user|
20 17
       check_for_time_left
21 18
   end
@@ -123,6 +120,22 @@ class Mission < ActiveRecord::Base
123 120
     end
124 121
   end
125 122
   
123
+  # LAUNCH
124
+  def launch
125
+    if self.status == 1 || self.status == nil
126
+      if self.duration_scale == "days"
127
+        self.end_date = self.duration_number.days.from_now
128
+      elsif self.duration_scale == "hours"
129
+        self.end_date = self.duration_number.hours.from_now
130
+      end
131
+      self.launch_date = Time.now
132
+      self.status = 2
133
+      self.save
134
+      return true
135
+    end
136
+    return false
137
+  end
138
+  
126 139
   def completed
127 140
     self.update(status: 3)
128 141
     self.rewards.each do |reward|
@@ -186,12 +199,4 @@ class Mission < ActiveRecord::Base
186 199
     return array
187 200
   end
188 201
   
189
-  def duration_scale
190
-    
191
-  end
192
-  
193
-  def duration_number
194
-    
195
-  end
196
-  
197 202
 end

+ 1 - 1
app/models/submission_content.rb

@@ -4,7 +4,7 @@ class SubmissionContent < ActiveRecord::Base
4 4
   accepts_nested_attributes_for :submission, allow_destroy:true
5 5
   
6 6
   def build_submission(klass, object)
7
-    if klass = 'SubmissionText'
7
+    if klass == 'SubmissionText'
8 8
       submission = SubmissionText.new(object)
9 9
       self.submission_type = klass
10 10
     end

+ 1 - 1
app/views/mission_editor/agents/index.html.erb

@@ -39,7 +39,7 @@
39 39
 			     <%= content_tag(:div, class: "form-submit-center") do %>
40 40
 			     	<%= content_tag(:p) do %>
41 41
 						<%= link_to (t'nav.back'), rewards_path(@mission), class: 'btn spacer-right-small' %>
42
-						<%= link_to((t'nav.next'), '#', class: 'btn btn-success')%>
42
+						<%= link_to((t'nav.next'), mission_editor_launch_path(@mission), class: 'btn btn-success')%>
43 43
 					<% end %>
44 44
 					<%= content_tag(:p) do %>
45 45
 						<%= link_to (t'mission_editor.continue_later'), missions_path, class: 'btn btn-link btn-danger' %>

+ 53 - 0
app/views/mission_editor/details/launch.html.erb

@@ -0,0 +1,53 @@
1
+<%= render :partial => 'missions/mission_editor_tabs' %>
2
+
3
+
4
+
5
+<%= content_tag(:div, class: 'container-bg') do %>
6
+	<%= content_tag(:div, class: 'container container-bg mission-detail-container') do %>
7
+		<%= content_tag(:div, class: 'row') do %>
8
+			<%= content_tag(:div, class: 'span12') do %>
9
+				
10
+				<%= content_tag(:div, class: 'page-header page-header-type') do %>
11
+					<%= content_tag(:small, @mission.title + ':') %>
12
+					<%= content_tag(:h1) do %>
13
+						<%= t 'mission_editor.launch_mission' %> 
14
+					<% end %>
15
+				<% end %>
16
+				
17
+			<% end%>
18
+		<% end %>
19
+		<%= content_tag(:div, class: 'row') do %>
20
+			<%= content_tag(:div, class: 'span8') do %>
21
+			     <%= content_tag(:div, class: "form-submit-center") do %>
22
+			     	<%= content_tag(:p) do %>
23
+						<%= link_to (t'nav.back'), mission_agents_path(@mission), class: 'btn spacer-right-small' %>
24
+						<%= link_to((t'mission_editor.review_mission'), mission_path(@mission), class: 'btn')%>
25
+						<%= link_to((t'mission_editor.launch_mission'), launch_mission_path(@mission), class: 'btn btn-success btn-huge')%>
26
+						<%= link_to (t'mission_editor.continue_later'), missions_path, class: 'btn btn-link btn-danger' %>
27
+					<% end %>
28
+					
29
+				<% end %>
30
+			<% end %>
31
+			<% # Sidebar %>
32
+			<%= content_tag(:div, class: 'span4') do %>
33
+			     <%= content_tag(:div, class: 'panel panel-default') do %>
34
+			     	<%= content_tag(:div, class: 'panel-body white-bg') do %>
35
+				   		<%= content_tag(:div, class: "panel-content") do %>
36
+				   			<%= content_tag(:div, class: "panel-text") do %>
37
+								<%= content_tag(:h3, (t 'mission_editor.launch.before_launch')) %>
38
+								<%= content_tag(:div, (t 'mission_editor.launch.before_launch_help').html_safe, class: 'small-text') %>
39
+							<% end %>
40
+						<% end %>
41
+					<% end %>
42
+				<% end %>
43
+			<% end %>
44
+			
45
+		<% end %>
46
+		
47
+	<% end %>			
48
+<% end %>
49
+
50
+
51
+
52
+
53
+

+ 2 - 2
app/views/missions/_form.html.erb

@@ -11,8 +11,8 @@
11 11
 				    <%= f.select :language, [[(t 'mission_editor.mission_details.en'), 'en'], [(t 'mission_editor.mission_details.pt-BR'), 'pt-BR']], { label: (t 'mission_editor.mission_details.language') }, { class: "selectpicker" } %>
12 12
 					<%= render :partial => 'mission_image_uploader', locals: { mission: @mission, f: f } %>
13 13
 					<%= content_tag(:div, '', class: 'inline-form-line') do%>
14
-						<%= f.select :duration_scale, [[(t 'time.days'), 'days'], [(t 'time.hours'), 'hours']], { label: (t 'mission_editor.mission_details.mission_duration') }, { class: "selectpicker", layout: :inlin } %>
15
-						<%= f.text_field :duration_number, hide_label: true, placeholder: (t 'mission_editor.mission_details.duration') %>
14
+						<%= f.select :duration_scale, [[(t 'time.days'), 'days'], [(t 'time.hours'), 'hours']], { label: (t 'mission_editor.mission_details.mission_duration') }, { class: "selectpicker", layout: :inline } %>
15
+						<%= f.number_field :duration_number, hide_label: true, placeholder: (t 'mission_editor.mission_details.duration') %>
16 16
 					<% end %>
17 17
 				<% end %>
18 18
 			<% end %>

+ 1 - 1
app/views/missions/_mission_details.html.erb

@@ -75,7 +75,7 @@
75 75
 					<% end %>
76 76
 				<% elsif current_user == @mission.owner && @mission.status == 1 %>
77 77
 					<%= content_tag(:div, class: 'mission-call-to-action') do %>
78
-						<%= link_to (t 'mission.launch'), mission_launch_path(@mission), class: 'btn btn-large btn-primary' %>
78
+						<%= link_to (t 'mission.edit_mission'), mission_editor_launch_path(@mission), class: 'btn btn-large' %>
79 79
 					<% end %>
80 80
 				<% end %>
81 81
 				<%= content_tag(:div, '', class: 'clearfix', id: 'mission-tab') %>

+ 4 - 4
app/views/missions/_step_submission.html.erb

@@ -7,7 +7,7 @@
7 7
 				<%= link_to(('#'+ validation_id), class: 'accordion-toggle', :data => {toggle: 'collapse', parent: submission_id}) do %>
8 8
 					<%= content_tag(:span, validation.icon.html_safe, class: 'task-icon pull-left') %>
9 9
 					<%= content_tag(:span, '', class: 'caret caret-center') %>
10
-					<%= content_tag(:span, (step.step_validations.first.description != nil ? step.step_validations.first.validation.description : 'test'), class: 'task-text') %>
10
+					<%= content_tag(:span, (validation.description != nil ? validation.description : 'test'), class: 'task-text') %>
11 11
 				<% end %>
12 12
 				
13 13
 			<% end %>
@@ -15,16 +15,16 @@
15 15
 		<%= content_tag(:div, class: 'panel-body collapse', id: validation_id) do %>
16 16
 			<%= content_tag(:div, class: 'panel-content') do %>
17 17
 
18
-				<% last_step_submission = StepSubmission.find_all_by_agent_step_id(step.id).last %>
18
+				<% last_step_submission = StepSubmission.where(agent_step_id: step.id).last %>
19 19
 				<% if last_step_submission %>
20 20
 					<% if last_step_submission.validated == nil && current_user == last_step_submission.agent_step.mission_agent.user %>
21
-						<% # waiting for validation, draw the answer %>
21
+						<% # waiting for validation, draw the answer form %>
22 22
 						<%= render :partial => 'step_submission_content', locals: {step: step, f: f, last_step_submission: last_step_submission} %>
23 23
 					<% elsif last_step_submission.validated == false && current_user == last_step_submission.agent_step.mission_agent.user%>
24 24
 						<% # draw the form %>
25 25
 						<%= render :partial => 'step_submission_form', locals: {step: step, f: f, step_submission: step_submission} %>
26 26
 					<% else %>
27
-						<% # step completed, draw the answer%>
27
+						<% # step completed, draw the answer form %>
28 28
 						<%= render :partial => 'step_submission_content', locals: {step: step, f: f, last_step_submission: last_step_submission} %>
29 29
 					<% end%>
30 30
 				<% elsif agent.user == current_user %>

+ 6 - 7
app/views/missions/index.html.erb

@@ -7,7 +7,7 @@
7 7
 
8 8
 			<%= content_tag(:div, class: 'page-header') do %>
9 9
 				<%= content_tag(:h1) do %>
10
-					<%= t 'mission.missions' %> 
10
+					<%= t 'mission.missions' %>
11 11
 					<% if @featured_missions != nil && @open_missions != nil && @finished_missions != nil %>
12 12
 						<%= link_to (t'mission.new_mission'), new_mission_path, class: 'btn btn-success' %>
13 13
 					<% end %>
@@ -46,7 +46,7 @@
46 46
 
47 47
 
48 48
 			<% if @open_missions != nil %>
49
-				<% if @open_missions.count > 2 %>
49
+				<% if @open_missions.count > 0 && !@open_missions.empty? %>
50 50
 					<%= content_tag(:h2, (t 'mission.open_missions'))%>
51 51
 
52 52
 					<%= content_tag(:ul, class: 'thumbnails mission-list') do %>
@@ -68,10 +68,10 @@
68 68
 					<% end %>
69 69
 				<% end %>
70 70
 			<% end %>
71
-			
71
+
72 72
 			<% # Empty Page %>
73
-			
74
-			<% if @featured_missions == nil && @open_missions == nil && @finished_missions == nil %>
73
+
74
+			<% if @featured_missions == nil && (@open_missions == nil || @open_missions.empty?) && (@finished_missions == nil || @finished_missions.empty?) %>
75 75
 				<%= content_tag(:div, class: 'row') do %>
76 76
 					<%= content_tag(:ul, class: 'mission-editor-reward-list') do %>
77 77
 						<%= content_tag(:li, class: 'span12' ) do %>
@@ -84,10 +84,9 @@
84 84
 					<% end %>
85 85
 				<% end %>
86 86
 			<% end %>
87
-			
87
+
88 88
 			<% # End of Page Content %>
89 89
 
90 90
 		<% end %>
91 91
 	<% end %>
92 92
 <% end %>
93
-

+ 1 - 1
app/views/missions/show_agent_details.html.erb

@@ -72,7 +72,7 @@
72 72
 			<% @agent.agent_steps.order('step ASC').each do |step| %>
73 73
 				<% step_submission = StepSubmission.new %>
74 74
 				<%= bootstrap_nested_form_for(StepSubmission.new, url: step_submission_path(step: step.id, mission: @mission.slug, agent: @agent.slug)) do |f| %>
75
-					<%= content_tag(:div, class: 'panel panel-default') do %>
75
+					<%= content_tag(:div, class: 'panel panel-default', id: "step-#{step.position}") do %>
76 76
 						<%= content_tag(:div, class: 'panel-heading') do %>
77 77
 							<%= content_tag(:h3, class: 'panel-title') do %>
78 78
 								<%= content_tag(:span, step.position, class: 'task-number') %>

+ 9 - 1
config/locales/mission.en.yml

@@ -18,6 +18,11 @@ en:
18 18
     account: 'Account'
19 19
   mission_editor:
20 20
     continue_later: 'continue later'
21
+    launch_mission: 'Launch Mission'
22
+    review_mission: 'Review Mission'
23
+    mission_launched: 'The mission was launched succesfully.'
24
+    launch_error: 'An error ocured while launching this mission. Please try again later.'
25
+    insuficient_privileges: 'You dont have suficient privileges to access this page.'
21 26
     mission_details:
22 27
       save: 'Save'
23 28
       save_and_continue: 'Save & Continue'
@@ -46,4 +51,7 @@ en:
46 51
       save_agent: 'Save Agent'
47 52
       agent_details_help_title: 'Agent Details'
48 53
       agent_details_help: 'Some tips about agents... coming soon'
49
-      text_validation_description: 'Validation description'
54
+      text_validation_description: 'Validation description'
55
+    launch:
56
+      before_launch: 'Before Launch Tips'
57
+      before_launch_help: '<p>Check out this tips for some things to do before launching your mission.</p><ul><li>Review Your mission in the public view</li><li>Make sure you can deliver the rewards you promisse</li><li>Review agents and make sure everyone has steps with at least one validation</li></ul>'

+ 9 - 1
config/locales/mission.pt-BR.yml

@@ -18,6 +18,11 @@ pt-BR:
18 18
     account: 'Conta'
19 19
   mission_editor:
20 20
     continue_later: 'continuar depois'
21
+    launch_mission: 'Lançar Missão'
22
+    review_mission: 'Revisar Missão'
23
+    mission_launched: 'A missão foi lançada com successo.'
24
+    launch_error: 'Ocorreu um erro ao lançar a missão. Por favor tente de novo mais tarde.'
25
+    insuficient_privileges: 'Você não tem privilégios o suficiente para acessar está página.'
21 26
     mission_details:
22 27
       save: 'Salvar'
23 28
       save_and_continue: 'Salvar & Continuar'
@@ -46,4 +51,7 @@ pt-BR:
46 51
       save_agent: 'Salvar agente'
47 52
       agent_details_help_title: 'Detalhes do agente'
48 53
       agent_details_help: 'Algumas dicas sobre como criar agentes em breve...'
49
-      text_validation_description: 'Descreva a validação'
54
+      text_validation_description: 'Descreva a validação'
55
+    launch:
56
+      before_launch: 'Before Launch Tips'
57
+      before_launch_help: '<p>Check out this tips for some things to do before launching your mission.</p><ul><li>Review Your mission in the public view</li><li>Make sure you can deliver the rewards you promisse</li><li>Review agents and make sure everyone has steps with at least one validation</li></ul>'

+ 2 - 1
config/routes.rb

@@ -25,7 +25,6 @@ Avalanche2::Application.routes.draw do
25 25
   # Missions
26 26
   resources :missions
27 27
   get 'missions/:id/agents', to: 'missions#show_agents', as: :mission_agents_list
28
-  get 'missions/:id/launch', to: 'missions#launch', as: :mission_launch
29 28
   get 'missions/:id/agents/:agent', to: 'missions#show_agent_details', as: :mission_agent_details
30 29
   get 'missions/:id/agents/:agent/take_agent_role', to: 'missions#take_agent_role', as: :take_agent_role
31 30
   
@@ -40,6 +39,8 @@ Avalanche2::Application.routes.draw do
40 39
   scope 'missions/:mission/editor' do
41 40
     resources :rewards, :controller => "mission_editor/rewards"
42 41
     resources :mission_agents, :controller => "mission_editor/agents", path: '/agents'
42
+    get  '/launch', :controller => "mission_editor/details", :action => "launch", as: :mission_editor_launch
43
+    get  '/launch_mission', :controller => "mission_editor/details", :action => "launch_mission", as: :launch_mission
43 44
     post  '/sort_steps', :controller => "mission_editor/agents", :action => "sort_steps", as: :sort_agent_steps
44 45
   end
45 46
 

+ 7 - 0
db/migrate/20150317210134_add_duration_to_mission.rb

@@ -0,0 +1,7 @@
1
+class AddDurationToMission < ActiveRecord::Migration
2
+  def change
3
+    add_column :missions, :duration_scale, :string
4
+    add_column :missions, :duration_number, :integer
5
+    add_column :missions, :launch_date, :datetime
6
+  end
7
+end

+ 5 - 0
db/migrate/20150317234308_add_deafult_value_to_missions.rb

@@ -0,0 +1,5 @@
1
+class AddDeafultValueToMissions < ActiveRecord::Migration
2
+  def change
3
+    change_column :missions, :status, :integer, default: 1
4
+  end
5
+end

+ 5 - 2
db/schema.rb

@@ -11,7 +11,7 @@
11 11
 #
12 12
 # It's strongly recommended that you check this file into your version control system.
13 13
 
14
-ActiveRecord::Schema.define(version: 20150315034117) do
14
+ActiveRecord::Schema.define(version: 20150317234308) do
15 15
 
16 16
   # These are extensions that must be enabled in order to support this database
17 17
   enable_extension "plpgsql"
@@ -140,7 +140,7 @@ ActiveRecord::Schema.define(version: 20150315034117) do
140 140
     t.string   "objective"
141 141
     t.text     "briefing"
142 142
     t.integer  "owner_id"
143
-    t.integer  "status"
143
+    t.integer  "status",            default: 1
144 144
     t.boolean  "launched"
145 145
     t.string   "language"
146 146
     t.string   "cover_img"
@@ -149,6 +149,9 @@ ActiveRecord::Schema.define(version: 20150315034117) do
149 149
     t.string   "slug"
150 150
     t.datetime "end_date"
151 151
     t.integer  "rewards_id"
152
+    t.string   "duration_scale"
153
+    t.integer  "duration_number"
154
+    t.datetime "launch_date"
152 155
   end
153 156
 
154 157
   add_index "missions", ["mission_agents_id"], name: "index_missions_on_mission_agents_id", using: :btree

+ 43 - 20
features/missions_view.feature

@@ -11,31 +11,38 @@ Feature: Missions
11 11
 	| Test 001     | 1 2 3 testing              | Testing the website                                             | 2      |
12 12
 	| Bank Robbery | Rob a bank and get rich    | The target will be Fort Knox. Only expert agents allowed.       | 2      |
13 13
 	And the the mission "Bank Robbery" has the following rewards
14
-	| title        | description                  | img      |
14
+	| title        | description                  | img       |
15 15
 	| 1M Dollars   | You get 1.000.000,00 dollars | money.png |
16 16
 	| 200K Dollars | You get 200.000,00 dollars   | money.png |
17 17
 	And the the mission "Bank Robbery" has the following agents
18 18
 	| role         | objective                  | briefing                                                        | description |
19
-	| Mr. Pink     | Get the inside the vault   | Find the manager, make him open the vault and get all the money |             | 
20
-	| Mr. Blue     | Take care of the hostages  | Make sure the hostages dont try anything stupid.                |             | 
21
-	| Mr. Green    | Drive the gettaway car     | Wait for the others to return and lose the cops.                |             | 
19
+	| Mr. Pink     | Get the inside the vault   | Find the manager, make him open the vault and get all the money |             |
20
+	| Mr. Blue     | Take care of the hostages  | Make sure the hostages dont try anything stupid.                |             |
21
+	| Mr. Green    | Drive the gettaway car     | Wait for the others to return and lose the cops.                |             |
22 22
 	And the agent "Mr. Pink" in the mission "Bank Robbery" has the following steps
23
-	| step | title                      | description                                                | completed |
24
-	| 1    | Get to the bank            | Make everbody surrender                                    | false     |
25
-	| 2    | Find the bank manager      | Find the bank manager with the vault keys                  | false     |
26
-	| 3    | Open the vault             | Use the keys to open the vault                             | false     |
27
-	| 4    | Get the money              | Put all the money in the bag                               | false     |
28
-	| 5    | Leave the bank             | Exit the bank and get to the getaway car                   | false     |
29
-	And the agent "Mr. Blue" in the mission "Bank Robbery" has the following steps               
30
-	| step | title                      | description                                                | completed |
31
-	| 1    | Get to the bank            | Make everbody surrender                                    | false     |
32
-	| 2    | Secure the hostages        | Secure the hostages while Mr. pink gets the vault          | false     |
33
-	| 3    | Leave the bank             | Exit the bank and get to the getaway car                   | false     |
34
-	And the agent "Mr. Green" in the mission "Bank Robbery" has the following steps              
35
-	| step | title                      | description                                                | completed |
36
-	| 1    | Get a good car for the job | Find a good car for the mission                            | false     |
37
-	| 2    | Take everbody to the bank  | Take Mr. Pink and Mr. Blue to the bank                     | false     |
38
-	| 3    | Getaway                    | Wait for Mr. Pink and Mr. Blue to return and lose the cops | false     |
23
+	| position | title                      | description                                                | completed |
24
+	| 1        | Get to the bank            | Make everbody surrender                                    | false     |
25
+	| 2        | Find the bank manager      | Find the bank manager with the vault keys                  | false     |
26
+	| 3        | Open the vault             | Use the keys to open the vault                             | false     |
27
+	| 4        | Get the money              | Put all the money in the bag                               | false     |
28
+	| 5        | Leave the bank             | Exit the bank and get to the getaway car                   | false     |
29
+     And the step "Get to the bank" from agent "Mr. Pink" in the mission "Bank Robbery" has the following validations
30
+     | validation_type | description                       |
31
+     | ValidationText  | What time did you arrive?         |
32
+	| ValidationText  | How many hostages where there?    |
33
+     And the step "Find the bank manager" from agent "Mr. Pink" in the mission "Bank Robbery" has the following validations
34
+     | validation_type | description                       |
35
+     | ValidationText  | What is the bank manager's name?  |
36
+	And the agent "Mr. Blue" in the mission "Bank Robbery" has the following steps
37
+	| position | title                      | description                                                | completed |
38
+	| 1        | Get to the bank            | Make everbody surrender                                    | false     |
39
+	| 2        | Secure the hostages        | Secure the hostages while Mr. pink gets the vault          | false     |
40
+	| 3        | Leave the bank             | Exit the bank and get to the getaway car                   | false     |
41
+	And the agent "Mr. Green" in the mission "Bank Robbery" has the following steps
42
+	| position | title                      | description                                                | completed |
43
+	| 1        | Get a good car for the job | Find a good car for the mission                            | false     |
44
+	| 2        | Take everbody to the bank  | Take Mr. Pink and Mr. Blue to the bank                     | false     |
45
+	| 3        | Getaway                    | Wait for Mr. Pink and Mr. Blue to return and lose the cops | false     |
39 46
 	And the agent "Mr. Pink" in the mission "Bank Robbery" has the reward "1M Dollars"
40 47
 	And the agent "Mr. Blue" in the mission "Bank Robbery" has the reward "1M Dollars"
41 48
 	And the agent "Mr. Green" in the mission "Bank Robbery" has the reward "200K Dollars"
@@ -75,5 +82,21 @@ Feature: Missions
75 82
 		And I should see "Mr. Green"
76 83
 		And within "#agent-mr-green" I should see "200K Dollars"
77 84
 		
85
+	Scenario: View mission agent details
86
+		When I go to the missions page
87
+		And I click in the link "Bank Robbery"
88
+		And within "#mission-tabs-nav" I click in the link "Agents"
89
+		And within "#agent-mr-pink" I click in the link "Mr. Pink"
90
+		Then I should see "Get the inside the vault"
91
+		And I should see "Find the manager, make him open the vault and get all the money"
92
+		And I should see "Get to the bank"
93
+		And within "#step-1" I should see "Make everbody surrender"
94
+		And within "#step-1" I should see "What time did you arrive?"
95
+		And within "#step-1" I should see "How many hostages where there?"
96
+		And I should see "Find the bank manager"
97
+		And within "#step-2" I should see "What is the bank manager's name?"
98
+		And I should see "Open the vault"
99
+		And I should see "Get the money"
100
+		And I should see "Leave the bank"
78 101
 		
79 102
 		

+ 11 - 0
features/step_definitions/mission_steps.rb

@@ -41,4 +41,15 @@ Given(/^the agent "(.*?)" in the mission "(.*?)" has the reward "(.*?)"$/) do |a
41 41
   reward = Reward.where(title: arg3).first
42 42
   reward.mission_agents << agent
43 43
   reward.save
44
+end
45
+
46
+Given(/^the step "(.*?)" from agent "(.*?)" in the mission "(.*?)" has the following validations$/) do |arg1, arg2, arg3, table|
47
+  mission = Mission.where(title: arg3).first
48
+  agent = MissionAgent.where(role: arg2, mission_id: mission).first
49
+  step = agent.agent_steps.where(title: arg1, mission_agent_id: agent).first
50
+  table.hashes.each do |hash|
51
+    validation = FactoryGirl.create("step_validation", hash)
52
+    validation.agent_step = step
53
+    validation.save
54
+  end
44 55
 end

+ 5 - 0
spec/factories.rb

@@ -61,6 +61,11 @@ FactoryGirl.define do
61 61
     f.description "Do this thing like this."
62 62
     f.completed    false
63 63
   end
64
+  
65
+  factory :step_validation do |f|
66
+    f.validation_type "ValidationText"
67
+    f.description "Do this thing like this."
68
+  end
64 69
 
65 70
   factory :reward do |f|
66 71
     f.title       "Cool Reward"